package com.yudaxian.sys.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yudaxian.sys.entity.Pipe;
import com.yudaxian.sys.entity.Pipe;
import com.yudaxian.sys.mapper.PipeMapper;
import com.yudaxian.sys.service.IPipeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yudaxian
 * @since 2023-12-13
 */
@Service
public class PipeServiceImpl extends ServiceImpl<PipeMapper, Pipe> implements IPipeService {

    @Resource
    private PipeMapper pipeMapper;

    @Override
    public Pipe getPipeById(Integer id) {
        return this.baseMapper.selectById(id);
    }

    @Override
    public void addPipe(Pipe pipe) {
        this.baseMapper.insert(pipe);
    }

    @Override
    public void updatePipe(Pipe pipe) {
        this.baseMapper.updateById(pipe);
    }

    @Override
    public void deletePipeById(Integer id) {
        this.baseMapper.deleteById(id);
    }

    @Override
    public PageInfo<Pipe> selectPage(String pipeName, Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo, pageSize);
        List<Pipe> list = pipeMapper.selectAll(pipeName);
        return PageInfo.of(list);
    }


}
